/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rbh.visanyee.entity;

import java.io.Serializable;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 *
 * @author M
 */
@Entity
@Table(name = "rbh_risk_privilege")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@XmlRootElement
public class Privilege implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PRIVILEGE_ID", unique = true, nullable = false, columnDefinition = "int UNSIGNED")
    private Integer privilegeId;
    @JoinColumn(name = "RBH_RISK_ROLE", referencedColumnName = "ROLE_ID", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY)
    private Role role;
    @JoinColumn(name = "RBH_RISK_ACL", referencedColumnName = "ACL_ID", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY)
    private ACL acl;

    public Privilege() {
    }

    public Privilege(Integer privilegeId) {
        this.privilegeId = privilegeId;
    }

    public Integer getPrivilegeId() {
        return privilegeId;
    }

    public void setPrivilegeId(Integer privilegeId) {
        this.privilegeId = privilegeId;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public ACL getAcl() {
        return acl;
    }

    public void setAcl(ACL acl) {
        this.acl = acl;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (privilegeId != null ? privilegeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Privilege)) {
            return false;
        }
        Privilege other = (Privilege) object;
        if ((this.privilegeId == null && other.privilegeId != null) || (this.privilegeId != null && !this.privilegeId.equals(other.privilegeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rbh.risk.entity.Privilege[ privilegeId=" + privilegeId + " ]";
    }
}
